define(['jquery'], function ($) {
    return function ajax(url, params, done, isPost) {
                var result = null;
                if (typeof done !== 'function')
                    done = null;

                $.ajax({
                    url: url,
                    dataType: 'json',
                    data: isPost === true ? JSON.stringify(params) : params,
                    async: done !== null,
                    type: isPost === true ? "POST" : "GET",
                    contentType: 'application/json'
                }).done(function (resp, textStatus, jqXHR) {
                    try {
                        if (done !== null)
                            done(resp, textStatus, jqXHR);
                        else
                            result = resp;
                    }
                    catch (err) {
                        var errorMessage = err.stack || err;
                        console.log(errorMessage);
                    }
                }).error(function (resp) {
                    try {
                        var error = JSON.parse(resp.responseText);
                        console.log(error.Message);
                    }
                    catch (err) {
                        var errorMsg = resp.statusText ? resp.statusText : err.message;
                        console.log(errorMsg);
                    }
                });
                return result;
            };
})